from models import Captcha

def validate(key,answer):
	"""
		returns True or False based on whether the passed-in key + answer combination is correct(exists in the database).
		Does it's best to clean up after itself following
		TODO: make it clean up a little more - something like a date_created on the captchas,
		and then cleaning any more than an hour old or something
	"""
	return_value = False
	try:
		Captcha.objects.get(answer=answer,key=key)
		return_value = True
	except Captcha.DoesNotExist:
		pass
	# delete the object they tried on(hopefully the key wasn't the thing that didn't match)
	# try:
	# 	me = Captcha.objects.get(key=key)
	# 	me.delete()
	# except Captcha.DoesNotExist:
	# 	return_value = False
	return return_value